#include "Scheduler.h"
#include "pwm.h"
#include "encode.h"
#include "config.h"
#include <REGF51RC.H>

#if USE_PWM
extern PWM pwm[2];
#endif

void ExInt0_Isr(void) interrupt 0
{
#if USE_ENCODE
	encodeTrigger(0);
#endif
}

void Timer0_Isr(void) interrupt 1
{
#if USE_PWM
	TL0 = pwm[0].set.set8[1];
	TH0 = pwm[0].set.set8[0];
	pwmLevel(0, 0);
	TR0 = 0;// 暂时停止计数
#endif
}

void ExInt1_Isr(void) interrupt 2
{
#if USE_ENCODE
	encodeTrigger(1);
#endif
}

void Timer1_Isr(void) interrupt 3
{
#if USE_PWM
	TL1 = pwm[1].set.set8[1];
	TH1 = pwm[1].set.set8[0];
	pwmLevel(1, 0);
	TR1 = 0; // 暂时停止计数
#endif
}

void Timer2_Isr(void) interrupt 5
{
	TF2 = 0;
#if USE_PWM
	pwmTigger();
#endif
	SysTick_Handler();
}
